package com.game;

import java.util.ArrayList;
import java.util.Collections;

public class Doudizhu {
    //定义一个54张牌的集合
    private  ArrayList<Card> list = new ArrayList();
    //定义牌的数字
    private  String[] str = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2"};

    //主函数
    public static void main(String[] args) {
        Doudizhu ddz = new Doudizhu();
        ddz.init();
        ddz.xipai();
        ddz.fapai();
    }

    // 初始化54张扑克牌
    //先把牌给上花色
    public void init() {
        for (int i = 0; i < str.length; i++) {
            list.add(new Card(str[i], "♠"));
            list.add(new Card(str[i], "♥"));
            list.add(new Card(str[i], "♣"));
            list.add(new Card(str[i], "♦"));
        }
        //添加大小王
        list.add(new Card("小王", ""));
        list.add(new Card("大王", ""));
        System.out.println(list);
    }

    // 洗牌
    public void xipai() {
        //shuffle(List<?> list)
        Collections.shuffle(list);
        System.out.println(list);
    }

    // 发牌
    public void fapai() {
        //subList (int fromIndex, int toIndex) fromIndex （包含）和toIndex （不包括）
        //玩家1：0-17 玩家2:17-34 玩家3:34-51 底牌堆51-54
        System.out.println("玩家a手牌：" + list.subList(0, 17));
        System.out.println("玩家b手牌：" + list.subList(17, 34));
        System.out.println("玩家c手牌：" + list.subList(34, 51));
        System.out.println("底牌3张：" + list.subList(51, 54));
    }
    //排序
}
